﻿using OxyPlot;
using OxyPlot.Axes;
using OxyPlot.Wpf;
using OxyPlotChartingDemo;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace OxyplotChartingUsingPlotModel
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            
            PlotView plotView = new PlotView();


            var model = new PlotModel { Title = "Show tracker without clicking" };
            model.Axes.Add(new OxyPlot.Axes.LinearAxis { Position = AxisPosition.Bottom });
            model.Axes.Add(new OxyPlot.Axes.LinearAxis { Position = AxisPosition.Left });
            //model.Series.Add(new FunctionSeries(t => (Math.Cos(t) * 5) + Math.Cos(t * 50), t => (Math.Sin(t) * 5) + Math.Sin(t * 50), 0, Math.PI * 2, 20000));


            var lineSeries1 = new OxyPlot.Series.LineSeries();
            lineSeries1.Title = "LineSeries 1";


            MainViewModel viewModel = new MainViewModel();
            lineSeries1.ItemsSource = viewModel.SuccessPoints;

            var lineSeries2 = new OxyPlot.Series.LineSeries();
            lineSeries2.Title = "LineSeries 2";
            lineSeries2.ItemsSource = viewModel.FailurePoints;

            model.Series.Add(lineSeries1);
            model.Series.Add(lineSeries2);


            // create a new plot controller with default bindings
            var controller = new PlotController();

            // add a tracker command to the mouse enter event
            controller.BindMouseEnter(OxyPlot.PlotCommands.HoverTrack);

            plotView.Model = model;
            plotView.Controller = controller;


            grdMain.Children.Add(plotView);
        }
    }
}
